<template>
  <div class="basicBox">
    <div class="title-box">
      <div class="title-head">基础配置</div>
      <div class="title-hint">
        <el-switch v-model="configForm.basisStatus" active-text="已开启" inactive-text="已关闭"></el-switch>
      </div>
    </div>
    <p class="top-hint">说明：开启该功能后，学员进入商品页面可针对商品分享，邀请购买成功可获得相应奖励。</p>
    <el-form v-if="configForm.basisStatus" ref="configForm" :model="configForm" label-width="100px">
      <el-form-item label="分销使用权限">
        <el-radio-group v-model="configForm.Jurisdiction">
          <el-radio label="registerUser">注册用户</el-radio>
          <el-radio label="vipUser">会员</el-radio>
          <el-radio label="buyVipUser">购买过课程的会员</el-radio>
        </el-radio-group>
      </el-form-item>
      <p class="top-hint">说明：设置使用权限后，会为每位拥有权限的人员发放一个固定的邀请码，可重复使用。</p>
      <div class="second-title">被邀请人消费后邀请人获得奖励</div>
      <el-form-item label="奖励">
        <div class="optionBox">
          <div class="option-left">
            <el-checkbox-group v-model="configForm.checkList" @change="bindCheckBox">
              <el-checkbox label="积分">积分</el-checkbox>
              <el-checkbox label="余额">余额</el-checkbox>
              <el-checkbox label="积分提成">积分提成</el-checkbox>
              <el-checkbox label="余额提成">余额提成</el-checkbox>
            </el-checkbox-group>
          </div>
          <div class="option-right">
            <el-input
              v-model="configForm.integralValue"
              :disabled="configForm.checkList[0]!=='积分'"
              size="small"
              style="width:200px;"
            ></el-input>
            <el-input
              v-model="configForm.balanceValue"
              :disabled="configForm.checkList[0]!=='余额'"
              size="small"
              style="width:200px;"
            ></el-input>
            <div class="tooltip-box">
              <el-input
                v-model="configForm.integralRakeValue"
                :disabled="configForm.checkList[0]!=='积分提成'"
                size="small"
                placeholder="%"
                style="width:200px;"
              ></el-input>
              <el-tooltip
                class="item"
                effect="dark"
                content="说明：提成按用户线上实付款金额计算，奖励以积分的形式发放到邀请人的个人中心"
                placement="right"
              >
                <i class="el-icon-question"></i>
              </el-tooltip>
            </div>
            <div class="tooltip-box">
              <el-input
                v-model="configForm.balanceRakeValue"
                :disabled="configForm.checkList[0]!=='余额提成'"
                size="small"
                placeholder="%"
                style="width:200px;"
              ></el-input>
              <el-tooltip
                class="item"
                effect="dark"
                content="说明：提成按用户线上实付款金额计算，奖励以余额的形式发放到邀请人的个人中心"
                placement="right"
              >
                <i class="el-icon-question"></i>
              </el-tooltip>
            </div>
          </div>
        </div>
      </el-form-item>
      <div class="second-box">
        <div class="second-title">开启两级邀请</div>
        <div class="title-hint">
          <el-switch v-model="configForm.secondStatus" active-text="已开启" inactive-text="已关闭"></el-switch>
        </div>
      </div>
      <p class="top-hint">说明：开启该功能后，学员进入商品页面可针对商品分享，邀请购买成功可获得相应奖励。</p>
      <div v-if="configForm.secondStatus">
        <el-form-item label="奖励">
          <div class="optionBox">
            <div class="option-left">
              <el-checkbox-group v-model="configForm.sonCheckList" @change="secondBindCheckBox">
                <el-checkbox label="积分">积分</el-checkbox>
                <el-checkbox label="余额">余额</el-checkbox>
                <el-checkbox label="积分提成">积分提成</el-checkbox>
                <el-checkbox label="余额提成">余额提成</el-checkbox>
              </el-checkbox-group>
            </div>
            <div class="option-right">
              <el-input
                v-model="configForm.sonIntegralValue"
                :disabled="configForm.sonCheckList[0]!=='积分'"
                size="small"
                style="width:200px;"
              ></el-input>
              <el-input
                v-model="configForm.sonBalanceValue"
                :disabled="configForm.sonCheckList[0]!=='余额'"
                size="small"
                style="width:200px;"
              ></el-input>
              <div class="tooltip-box">
                <el-input
                  v-model="configForm.sonIntegralRakeValue"
                  :disabled="configForm.sonCheckList[0]!=='积分提成'"
                  size="small"
                  placeholder="%"
                  style="width:200px;"
                ></el-input>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="说明：提成按用户线上实付款金额计算，奖励以积分的形式发放到邀请人的个人中心"
                  placement="right"
                >
                  <i class="el-icon-question"></i>
                </el-tooltip>
              </div>
              <div class="tooltip-box">
                <el-input
                  v-model="configForm.sonBalanceRakeValue"
                  :disabled="configForm.sonCheckList[0]!=='余额提成'"
                  size="small"
                  placeholder="%"
                  style="width:200px;"
                ></el-input>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="说明：提成按用户线上实付款金额计算，奖励以余额的形式发放到邀请人的个人中心"
                  placement="right"
                >
                  <i class="el-icon-question"></i>
                </el-tooltip>
              </div>
            </div>
          </div>
        </el-form-item>
      </div>
      <el-button type="primary" style="margin:20px 0 20px 400px;">保 存</el-button>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      configForm: {
        basisStatus: true,
        secondStatus: true,
        Jurisdiction: 'buyVipUser',
        checkList: ['积分'],
        integralValue: '',
        balanceValue: '',
        integralRakeValue: '',
        balanceRakeValue: '',
        sonCheckList: ['积分'],
        sonIntegralValue: '',
        sonBalanceValue: '',
        sonIntegralRakeValue: '',
        sonBalanceRakeValue: '',
      }
    }
  },
  methods: {
    bindCheckBox(value) {
      this.configForm.checkList = [];
      this.configForm.checkList.push(value[1])
      this.configForm.integralValue = ''
      this.configForm.balanceValue = ''
      this.configForm.integralRakeValue = ''
      this.configForm.balanceRakeValue = ''
    },
    secondBindCheckBox(value) {
      this.configForm.sonCheckList = [];
      this.configForm.sonCheckList.push(value[1])
      this.configForm.sonIntegralValue = ''
      this.configForm.sonBalanceValue = ''
      this.configForm.sonIntegralRakeValue = ''
      this.configForm.sonBalanceRakeValue = ''
    }
  }
}
</script>
<style lang="scss" scoped>
.basicBox {
  padding: 0 20px;
.title-box {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background-color: #fff0f5;
  border-bottom: 1px solid #eee;
  .title-head {
    font-size: 14px;
  }
  .title-hint {
    margin-left: 40px;
    font-size: 12px;
  }
}
.top-hint {
  font-size: 14px;
  color: #93999f;
  line-height: 20px;
}
.second-title {
  font-size: 16px;
  margin: 20px 0;
}
.optionBox {
  display: flex;
  .option-left {
    /deep/.el-checkbox-group {
      width: 100px;
      .el-checkbox {
        display: block;
      }
    }
  }
  .option-right {
    width: 300px;
    .tooltip-box {
      display: flex;
      i {
        font-size: 18px;
        margin: 8px;
      }
    }
  }
}
.second-box {
  display: flex;
  align-items: center;
  .title-hint {
    margin-left: 40px;
    font-size: 12px;
  }
}
}
</style>
